package com.yc.bran.snack.bean;


import java.time.LocalDate;

import javax.persistence.Id;

import org.bson.types.ObjectId;
import org.springframework.data.mongodb.core.mapping.Document;

@Document(collection = "replycomment") 
public class ReplyComment {
	@Id 
	private ObjectId id; // MongoDB自动生成ObjectId，这里为了简单起见使用String
	private int replycommentPrId; // 评论文章所属id
	private int gid;	// 商品id
	private String replycommentUserAvatar; // 评论用户头像  
	private String replycommentUserName; // 评论人昵称  
	private String replycommentText; // 评论内容  
	private LocalDate replycommentTime; // 评论时间  
	private String parentId; // 评论所属评论id，默认为null  
	private String replyName; // 回复评论用户的昵称
	
	@Override
	public String toString() {
		return "Replycomment [id=" + id + ", replycommentPrId=" + replycommentPrId + ", gid=" + gid
				+ ", replycommentUserAvatar=" + replycommentUserAvatar + ", replycommentUserName="
				+ replycommentUserName + ", replycommentText=" + replycommentText + ", replycommentTime="
				+ replycommentTime + ", parentId=" + parentId + ", replyName=" + replyName + "]";
	}

	public ReplyComment() {
		super();
	}

	public ReplyComment(ObjectId id, int replycommentPrId, int gid, String replycommentUserAvatar,
			String replycommentUserName, String replycommentText, LocalDate replycommentTime, String parentId,
			String replyName) {
		super();
		this.id = id;
		this.replycommentPrId = replycommentPrId;
		this.gid = gid;
		this.replycommentUserAvatar = replycommentUserAvatar;
		this.replycommentUserName = replycommentUserName;
		this.replycommentText = replycommentText;
		this.replycommentTime = replycommentTime;
		this.parentId = parentId;
		this.replyName = replyName;
	}

	public String getIdAsString() {  
		return id != null ? id.toHexString() : null;  
	}  

	// 如果需要，可以添加一个方法来设置ID（通常不需要，因为是由MongoDB自动设置的）  
	public void setId(ObjectId id) {  
		this.id = id;  
	}

	public int getReplycommentPrId() {
		return replycommentPrId;
	}

	public void setReplycommentPrId(int replycommentPrId) {
		this.replycommentPrId = replycommentPrId;
	}

	public int getGid() {
		return gid;
	}

	public void setGid(int gid) {
		this.gid = gid;
	}

	public String getReplycommentUserAvatar() {
		return replycommentUserAvatar;
	}

	public void setReplycommentUserAvatar(String replycommentUserAvatar) {
		this.replycommentUserAvatar = replycommentUserAvatar;
	}

	public String getReplycommentUserName() {
		return replycommentUserName;
	}

	public void setReplycommentUserName(String replycommentUserName) {
		this.replycommentUserName = replycommentUserName;
	}

	public String getReplycommentText() {
		return replycommentText;
	}

	public void setReplycommentText(String replycommentText) {
		this.replycommentText = replycommentText;
	}

	public LocalDate getReplycommentTime() {
		return replycommentTime;
	}

	public void setReplycommentTime(LocalDate replycommentTime) {
		this.replycommentTime = replycommentTime;
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public String getReplyName() {
		return replyName;
	}

	public void setReplyName(String replyName) {
		this.replyName = replyName;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + gid;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((parentId == null) ? 0 : parentId.hashCode());
		result = prime * result + ((replyName == null) ? 0 : replyName.hashCode());
		result = prime * result + replycommentPrId;
		result = prime * result + ((replycommentText == null) ? 0 : replycommentText.hashCode());
		result = prime * result + ((replycommentTime == null) ? 0 : replycommentTime.hashCode());
		result = prime * result + ((replycommentUserAvatar == null) ? 0 : replycommentUserAvatar.hashCode());
		result = prime * result + ((replycommentUserName == null) ? 0 : replycommentUserName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ReplyComment other = (ReplyComment) obj;
		if (gid != other.gid)
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (parentId == null) {
			if (other.parentId != null)
				return false;
		} else if (!parentId.equals(other.parentId))
			return false;
		if (replyName == null) {
			if (other.replyName != null)
				return false;
		} else if (!replyName.equals(other.replyName))
			return false;
		if (replycommentPrId != other.replycommentPrId)
			return false;
		if (replycommentText == null) {
			if (other.replycommentText != null)
				return false;
		} else if (!replycommentText.equals(other.replycommentText))
			return false;
		if (replycommentTime == null) {
			if (other.replycommentTime != null)
				return false;
		} else if (!replycommentTime.equals(other.replycommentTime))
			return false;
		if (replycommentUserAvatar == null) {
			if (other.replycommentUserAvatar != null)
				return false;
		} else if (!replycommentUserAvatar.equals(other.replycommentUserAvatar))
			return false;
		if (replycommentUserName == null) {
			if (other.replycommentUserName != null)
				return false;
		} else if (!replycommentUserName.equals(other.replycommentUserName))
			return false;
		return true;
	}
}
